<?php

namespace app\admin\controller\xilujob;

use app\common\controller\Backend;

/**
 * 
 *
 * @icon fa fa-circle-o
 */
class JobApply extends Backend
{
    
    /**
     * JobApply模型对象
     * @var \app\common\model\xilujob\JobApply
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\common\model\xilujob\JobApply;

    }

    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */
    public function index(){
        $this->relationSearch = true;
        $this->request->filter(['strip_tags']);
        if ($this->request->isAjax()) {
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
            $lists = $this->model
                ->with([
                    'user'=>function($query){$query->withField('id,nickname,avatar');},
                    'resume',
                    'job'=>function($query){$query->withField('id,job_name');},
                ])
                ->where($where)
                ->order('createtime','desc')
                ->paginate($limit)->each(function ($row){
                    $row->resume->relationQuery([ 'personal','works','summary']);
                });
            $result = array("total" => $lists->total(), "rows" => $lists->items());

            return json($result);
        }
        return $this->view->fetch();
    }


    public function add()
    {
        return;
    }
    public function edit($ids = NULL)
    {
        return;
    }
    public function del($ids = NULL)
    {
        return;
    }
    public function multi($ids = NULL)
    {
        return;
    }

}
